#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include "constantes.h"
#include "graphique.h"
#include "advancewars.h"

int main(int argc, char *argv[])
{
	
	player joueur1,joueur2;
	load_all_units();
	
	map carte;
    zone(carte);

    SDL_Surface *ecran = NULL;
    SDL_Event event;

    int continuer = 1;

    SDL_Init(SDL_INIT_VIDEO);
    TTF_Init();

    ecran = SDL_SetVideoMode(700, 510, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
    SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
    SDL_WM_SetCaption("Advance Wars", NULL);

	unit base1 = create_unit("infantry",1,5,4);
	base1.name = soldat;
	carte[5][4].occupied = 1;
    unit base2 = create_unit("recon",2,5,6);
    base2.name = soldat;
    carte[5][6].occupied = 1;
    unit tanki = create_unit("tank_lourd",1,5,8);
    tanki.name = tank;
    carte[5][8].occupied = 1;
    unit tanki2 = create_unit("tank",2,5,10);
    tanki2.name = tank;
    carte[5][10].occupied = 1;
    joueur1.armee[0] = base1;
    joueur1.armee[1] = tanki;
    joueur2.armee[0] = base2;
    joueur2.armee[1] = tanki2;
    
    affiche(carte, ecran, joueur1, joueur2);
    cursor(carte, ecran, &joueur1, &joueur2);
	
    while (continuer)
    {
        SDL_WaitEvent(&event);
        switch(event.type)
        {
            case SDL_QUIT:
                continuer = 0;
                break;
        }

        // Effacement de l'écran
        SDL_Flip(ecran);
    }

    SDL_Quit();
    TTF_Quit();

    return EXIT_SUCCESS;
}
